﻿using System.Text;
using System.Collections.Specialized;
using Newtonsoft.Json;

namespace CometDocs
{
    internal partial class Client
    {
        /// <summary>
        /// Get the list of all the entry-point names exposed by the CometDocs APi: https://www.cometdocs.com/developer/apiDocumentation#method-getMethods
        /// </summary>
        /// <returns>An array of strings.</returns>
        public string[] GetMethods()
        {
            byte[] result = webClient.UploadValues(APIRoot + "getMethods", new NameValueCollection());

            string json = Encoding.ASCII.GetString(result);

            GetMethodsResponse response = JsonConvert.DeserializeObject<GetMethodsResponse>(json);

            CheckAndThrow(response);

            return response.Methods;
        }
    }
}
